A function to convert a data frame to a JSON string. toJSONarray <- function(dtf){ clnms <- colnames(dtf) name.value <- function(i){ quote <- ''; if(!class(dtf[, i]) %in% c('numeric', 'integer')){ quote <- '"'; } paste('"', i, '" : ', quote, dtf[,i], quote, sep='') } objs <- apply(sapply(clnms, name.value), 1, function(x){paste(x, collapse=', ')}) objs <- paste('{', objs, '}') res <- paste('[', paste(objs, collapse=', '), ']') return(res) } With this function, the output will work in D3.js and Protovis: [ { "Petal.Width" : 0.2, "Species" : "setosa" }, { "Petal.Width" : 1.3, "Species" : "versicolor" }, { "Petal.Width" : 1.8, "Species" : "virginica" } ]